home *** CD-ROM | disk | FTP | other *** search
/ New Star Software Collection / NSS_Collection.iso / 3-004 ms visual basic pro 30 / 4.imz / 4.IMA / JOIN.FR_ / JOIN.bin
Text File  |  1993-04-28  |  5KB  |  182 lines

  1. VERSION 2.00
  2. Begin Form fJoin 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Join Tables"
  6.    ClientHeight    =   1935
  7.    ClientLeft      =   3510
  8.    ClientTop       =   1935
  9.    ClientWidth     =   5835
  10.    ControlBox      =   0   'False
  11.    Height          =   2340
  12.    Left            =   3450
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   1935
  17.    ScaleWidth      =   5835
  18.    Top             =   1590
  19.    Width           =   5955
  20.    Begin CommandButton ClearJoinsButton 
  21.       BackColor       =   &H00C0C0C0&
  22.       Caption         =   "C&lear All Joins"
  23.       Height          =   372
  24.       Left            =   2040
  25.       TabIndex        =   7
  26.       Top             =   1440
  27.       Width           =   1812
  28.    End
  29.    Begin CommandButton CloseButton 
  30.       BackColor       =   &H00C0C0C0&
  31.       Cancel          =   -1  'True
  32.       Caption         =   "&Close"
  33.       Height          =   372
  34.       Left            =   3960
  35.       TabIndex        =   6
  36.       Top             =   1470
  37.       Width           =   1812
  38.    End
  39.    Begin ListBox cFieldList2 
  40.       BackColor       =   &H00FFFFFF&
  41.       Height          =   1200
  42.       Left            =   3960
  43.       TabIndex        =   4
  44.       Tag             =   "OL"
  45.       Top             =   240
  46.       Width           =   1815
  47.    End
  48.    Begin ListBox cFieldList1 
  49.       BackColor       =   &H00FFFFFF&
  50.       Height          =   1200
  51.       Left            =   2040
  52.       TabIndex        =   3
  53.       Tag             =   "OL"
  54.       Top             =   240
  55.       Width           =   1815
  56.    End
  57.    Begin CommandButton AddJoinButton 
  58.       BackColor       =   &H00C0C0C0&
  59.       Caption         =   "&Add Join to Query"
  60.       Enabled         =   0   'False
  61.       Height          =   372
  62.       Left            =   120
  63.       TabIndex        =   1
  64.       Top             =   1440
  65.       Width           =   1812
  66.    End
  67.    Begin ListBox cTableList 
  68.       BackColor       =   &H00FFFFFF&
  69.       Height          =   1200
  70.       Left            =   120
  71.       MultiSelect     =   1  'Simple
  72.       TabIndex        =   0
  73.       Tag             =   "OL"
  74.       Top             =   240
  75.       Width           =   1815
  76.    End
  77.    Begin Label FieldsLabel 
  78.       Alignment       =   2  'Center
  79.       BackColor       =   &H00C0C0C0&
  80.       Caption         =   "Select Fields to Join Selected Tables on:"
  81.       Height          =   192
  82.       Left            =   2040
  83.       TabIndex        =   5
  84.       Top             =   0
  85.       Width           =   3732
  86.    End
  87.    Begin Label TableListLabel 
  88.       BackColor       =   &H00C0C0C0&
  89.       Caption         =   "Select Table Pair:"
  90.       Height          =   192
  91.       Left            =   120
  92.       TabIndex        =   2
  93.       Top             =   0
  94.       Width           =   1812
  95.    End
  96. End
  97. Option Explicit
  98. Dim FTbl1 As String
  99. Dim FTbl2 As String
  100.  
  101. Sub AddJoinButton_Click ()
  102.   Dim i As Integer
  103.  
  104.   fQuery.cJoinFields.AddItem FTbl1 + "." + cFieldList1 + "=" + FTbl2 + "." + cFieldList2
  105.  
  106.   For i = 0 To cTableList.ListCount - 1
  107.     cTableList.Selected(i) = False
  108.   Next
  109. End Sub
  110.  
  111. Sub cFieldList1_Click ()
  112.   If cFieldList2 <> "" Then
  113.     AddJoinButton.Enabled = True
  114.   End If
  115. End Sub
  116.  
  117. Sub cFieldList2_Click ()
  118.   If cFieldList1 <> "" Then
  119.     AddJoinButton.Enabled = True
  120.   End If
  121. End Sub
  122.  
  123. Sub ClearJoinsButton_Click ()
  124.   fQuery.cJoinFields.Clear
  125. End Sub
  126.  
  127. Sub CloseButton_Click ()
  128.   Unload Me
  129. End Sub
  130.  
  131. Sub cTableList_Click ()
  132.   Dim i As Integer
  133.   Dim t As TableDef
  134.  
  135.   FTbl1 = ""
  136.   FTbl2 = ""
  137.   cFieldList1.Clear
  138.   cFieldList2.Clear
  139.  
  140.   For i = 0 To cTableList.ListCount - 1
  141.     If cTableList.Selected(i) Then
  142.       If FTbl1 = "" Then
  143.         FTbl1 = cTableList.List(i)
  144.       Else
  145.         FTbl2 = cTableList.List(i)
  146.         Exit For
  147.       End If
  148.     End If
  149.   Next
  150.   
  151.   If FTbl2 = "" Then Exit Sub   'only one table selected
  152.  
  153.   Set t = gCurrentDB.TableDefs(FTbl1)
  154.   For i = 0 To t.Fields.Count - 1
  155.     cFieldList1.AddItem t.Fields(i).Name
  156.   Next
  157.  
  158.   Set t = gCurrentDB.TableDefs(FTbl2)
  159.   For i = 0 To t.Fields.Count - 1
  160.     cFieldList2.AddItem t.Fields(i).Name
  161.   Next
  162.  
  163. End Sub
  164.  
  165. Sub Form_Load ()
  166.   Dim i As Integer
  167.  
  168.   For i = 0 To fQuery.cTableList.ListCount - 1
  169.     If fQuery.cTableList.Selected(i) Then
  170.       cTableList.AddItem fQuery.cTableList.List(i)
  171.     End If
  172.   Next
  173.   Top = VDMDI.Top + fQuery.Top + fQuery.cCriteria.Top + 1300
  174.   Left = fQuery.Left + 1500
  175.   
  176. End Sub
  177.  
  178. Sub Form_Paint ()
  179.   Outlines Me
  180. End Sub
  181.  
  182.